Hello developers,
I use following code to start DOORS from VBA within Excel and execute a dxl script:
Sub CallDxlFunc()
DoorsObj.Result = "Sent from Excel"
The Problem is, that a Crash occurs at DoorsObj.runFile because no Login into the created and started DOORS instance has been done. The VBA code behaves asychron. Does anybody know how the program execution is only being continued after the Login into DOORS has been done?
Regards Marco MarcoLuk - Mon Nov 13 12:20:13 EST 2017 |
Re: Starting DOORS from VBA does not wait until login Would it be an option to ask for the credentials inside VB and run DOORS in "interactive batch" (i.e. start an interactive shell process, pass credentials over cmdline) instead of using COM? Regards, Mathias |
Re: Starting DOORS from VBA does not wait until login Mathias Mamsch - Wed Nov 15 05:04:39 EST 2017 Would it be an option to ask for the credentials inside VB and run DOORS in "interactive batch" (i.e. start an interactive shell process, pass credentials over cmdline) instead of using COM? Regards, Mathias Hello Mathias,
thanky for your answer. Yes, using the Shell-VBA-function is also possible, but we do not want to have all the detailed path data of DOORS as Argument. Meanwhile we force the user to manually start DOORS and login.
But we still have another Problem: Each time the function GetObject(, "DOORS.Application") crashes, even if DOORS has been started before. Everytime I get the following VBA-error: "Laufzeitfehler '429': Objekterstellung durch Active-X-Komponente nicht möglich".
Used Doors Client Version: 9.6.1.9 Used Windows: Windows 7 Enterprise, Service Pack 1, 64-Bit Used Excel Version for VBA-Code: Excel 2013
Does somebody have an idea, why this always Fails?
Regards, Marco |
Re: Starting DOORS from VBA does not wait until login MarcoLuk - Thu Nov 16 11:40:42 EST 2017 Hello Mathias,
thanky for your answer. Yes, using the Shell-VBA-function is also possible, but we do not want to have all the detailed path data of DOORS as Argument. Meanwhile we force the user to manually start DOORS and login.
But we still have another Problem: Each time the function GetObject(, "DOORS.Application") crashes, even if DOORS has been started before. Everytime I get the following VBA-error: "Laufzeitfehler '429': Objekterstellung durch Active-X-Komponente nicht möglich".
Used Doors Client Version: 9.6.1.9 Used Windows: Windows 7 Enterprise, Service Pack 1, 64-Bit Used Excel Version for VBA-Code: Excel 2013
Does somebody have an idea, why this always Fails?
Regards, Marco ( Hmm ... First: how to know if DOORS is running ...
The command 'tasklist /FO CSV" gives you the list of the processes runing.
I've done it once in DXL in order to prevent user to use 2 DOORS clients in the same time ... i can provide it as sample ... tell me if you need the split function ;)
Skip get_doors_processes() {
string temp = tempFileName()
command_system("tasklist /FO CSV > " temp "", 10 )
Skip skp_rez = null
Stream s_in = read temp
string s_ligne; int index = 0
string tmp
Regexp reg = regexp2("doors")
Skip sk_tmp
while ( true ) {
s_in >> s_ligne
if ( end s_in ) break
tmp = s_ligne[0:10]""
if ( tmp != "\"doors.exe\"" ) continue
sk_tmp = split(s_ligne, ',')
find(sk_tmp, 1, tmp)
if (null skp_rez) skp_rez = create()
put( skp_rez, index, tmp[1:length(tmp)-2]"")
index = index + 1
delete sk_tmp
}
close s_in
deleteFile(temp)
return skp_rez
}
(i let you see if it's running in the current session or not o;) )
If DOORS is running (in your session ...), just use the usual runFile feature ... if DOORS is not running ...
From VBA, you can create an empty temp file and use a .bat to launch DOORS executing a DXL that erase the empty file created by the VBA instance (-dxl option ... ). If the DXL has erased the file, then DOORS is lanched and you can go on ;) I let you figure how add a timer security ... Have fun !
) |
Re: Starting DOORS from VBA does not wait until login pommCannelle - Fri Nov 17 05:18:51 EST 2017 ( Hmm ... First: how to know if DOORS is running ...
The command 'tasklist /FO CSV" gives you the list of the processes runing.
I've done it once in DXL in order to prevent user to use 2 DOORS clients in the same time ... i can provide it as sample ... tell me if you need the split function ;)
Skip get_doors_processes() {
string temp = tempFileName()
command_system("tasklist /FO CSV > " temp "", 10 )
Skip skp_rez = null
Stream s_in = read temp
string s_ligne; int index = 0
string tmp
Regexp reg = regexp2("doors")
Skip sk_tmp
while ( true ) {
s_in >> s_ligne
if ( end s_in ) break
tmp = s_ligne[0:10]""
if ( tmp != "\"doors.exe\"" ) continue
sk_tmp = split(s_ligne, ',')
find(sk_tmp, 1, tmp)
if (null skp_rez) skp_rez = create()
put( skp_rez, index, tmp[1:length(tmp)-2]"")
index = index + 1
delete sk_tmp
}
close s_in
deleteFile(temp)
return skp_rez
}
(i let you see if it's running in the current session or not o;) )
If DOORS is running (in your session ...), just use the usual runFile feature ... if DOORS is not running ...
From VBA, you can create an empty temp file and use a .bat to launch DOORS executing a DXL that erase the empty file created by the VBA instance (-dxl option ... ). If the DXL has erased the file, then DOORS is lanched and you can go on ;) I let you figure how add a timer security ... Have fun !
) Hello pommCannelle,
thank you very much for your sample code. Until so far, I did not have time to try it. Now I started my DOORS Client (but no Login) and I could see the process "doors.exe" in the Task process Manager of Windows. So would your code this recognize? In that case, the recognizition would be too early for me.
Regards Marco |
Re: Starting DOORS from VBA does not wait until login MarcoLuk - Wed Nov 22 03:24:31 EST 2017 Hello pommCannelle,
thank you very much for your sample code. Until so far, I did not have time to try it. Now I started my DOORS Client (but no Login) and I could see the process "doors.exe" in the Task process Manager of Windows. So would your code this recognize? In that case, the recognizition would be too early for me.
Regards Marco Hmm... The idea was to use the result of the DOS command 'tasklist /FO CSV" BEFORE to launch DOORS, in order to know if you need to log and wait the effective start of DOORS or not. The sample was just to show a way to use the DOS command's result. You still need to do it in VB ... i'm pretty sure you can find how to do it in VB ;) |
Re: Starting DOORS from VBA does not wait until login MarcoLuk - Wed Nov 22 03:24:31 EST 2017 Hello pommCannelle,
thank you very much for your sample code. Until so far, I did not have time to try it. Now I started my DOORS Client (but no Login) and I could see the process "doors.exe" in the Task process Manager of Windows. So would your code this recognize? In that case, the recognizition would be too early for me.
Regards Marco Hi :)
Here after a sample to check if DOORS is running in your VBA word.
So first of all, at the start of your VBA code : Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) and where you want in your VBA code ...
Sub run_dxl(DXL As String)
'GET THE PROCESS LIST
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim oFile As Object
Set oFile = fso.CreateTextFile("D:\abatfile.bat", True)
oFile.WriteLine "tasklist /FO CSV > ""D:\temp_processlist.txt"""
oFile.Close
Set oFile = fso.CreateTextFile("D:\temp_processlist.txt", True)
oFile.Close
Set fso = Nothing
Set oFile = Nothing
Shell ("D:\abatfile.bat")
Sleep (100)
' READ THE PROCESS LIST
Dim fileNo As Integer, process_list As String
fileNo = FreeFile
Open "D:\temp_processlist.txt" For Input As #fileNo
process_list = Input$(LOF(fileNo), fileNo)
Close #fileNo
Sleep (100)
Kill "D:\abatfile.bat"
Kill "D:\temp_processlist.txt"
' TEST IF DOORS IS RUNING
If (InStr(1, process_list, "doors.exe", vbBinaryCompare) = 0) Then
'DOORS is not runing ... you need to open it properly
End
'NOW you can run your DXL
End Sub
I use to deal with some dedicated temp files in my projects ... easier for debug purpose. Have fun ! |
Re: Starting DOORS from VBA does not wait until login pommCannelle - Thu Nov 23 06:06:27 EST 2017 Hi :)
Here after a sample to check if DOORS is running in your VBA word.
So first of all, at the start of your VBA code : Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) and where you want in your VBA code ...
Sub run_dxl(DXL As String)
'GET THE PROCESS LIST
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim oFile As Object
Set oFile = fso.CreateTextFile("D:\abatfile.bat", True)
oFile.WriteLine "tasklist /FO CSV > ""D:\temp_processlist.txt"""
oFile.Close
Set oFile = fso.CreateTextFile("D:\temp_processlist.txt", True)
oFile.Close
Set fso = Nothing
Set oFile = Nothing
Shell ("D:\abatfile.bat")
Sleep (100)
' READ THE PROCESS LIST
Dim fileNo As Integer, process_list As String
fileNo = FreeFile
Open "D:\temp_processlist.txt" For Input As #fileNo
process_list = Input$(LOF(fileNo), fileNo)
Close #fileNo
Sleep (100)
Kill "D:\abatfile.bat"
Kill "D:\temp_processlist.txt"
' TEST IF DOORS IS RUNING
If (InStr(1, process_list, "doors.exe", vbBinaryCompare) = 0) Then
'DOORS is not runing ... you need to open it properly
End
'NOW you can run your DXL
End Sub
I use to deal with some dedicated temp files in my projects ... easier for debug purpose. Have fun ! Thank you very much again!
Meanwhile I could fix a general problem with my local doors client installation on my computer. I deinstalled and reinstalled the Client again, so that the COM mechanism ("Doors.Application") is working better. So with the command Set DoorsObj = GetObject("", "Doors.Application") I can obtain the running DOORS instance. The only wrong behaviour is if Doors is not running, in that case it starts Doors until the login prompt but does asynchronically continues VBA code execution with a failure.
I will try to test your code.
Marco |